package com.app.base.app;




import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.caszx.chargingpile.R;

/**
 * 带有个一TopBar的Activity
 * <p>
 * 
 * 主要用在一进入界面就要取数据，中间会有空白界面
 * <p>
 * 主要重写
 * <pre>
 * 	View initOnloadedView() {
 * 	   View view = getLayoutInflater().inflate(resid,getContentView(), true);
 *     return view
 * 	}
 * </pre>
 * 
 * 
 * 
 */
public abstract class BaseTopBarNetActivity extends BaseNetViewActivity {

	protected Toolbar mToolbar;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initToolSuperBar();
	}

	@Override
	protected void init() {

	}

	@Override
	protected ViewGroup initRootView() {
		ViewGroup group = (ViewGroup) getLayoutInflater().inflate(
				R.layout.base_netwith_topbar, null);
		rootView = (RelativeLayout) group.findViewById(R.id.ViewContent);
		return group;
	}

	@Override
	public ViewGroup getContentView() {
		return rootView;
	}
	protected void setCenterTitle(String title) {
		TextView centerTitle = (TextView) findViewById(R.id.center_title);
		centerTitle.setText(title);
	}
	protected void setCenterTitle(int resId) {
		TextView centerTitle = (TextView) findViewById(R.id.center_title);
		centerTitle.setText(resId);
	}

	protected void initToolSuperBar() {
		mToolbar = (Toolbar) findViewById(R.id.toolbar);
		mToolbar.setVisibility(View.VISIBLE);
		mToolbar.setTitleTextColor(getResources().getColor(R.color.white));
		mToolbar.setTitle("");
		setSupportActionBar(mToolbar);
		mToolbar.setBackgroundColor(getResources()
				.getColor(R.color.toolbarColor));
		mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				onBackPressed();
			}
		});
		getSupportActionBar().setHomeButtonEnabled(true);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);

	}
	
	protected Toolbar getToolbar(){
		
		return mToolbar;
	}
}
